package com.cupk.service.impl;

import com.cupk.common.PageResult;
import com.cupk.dto.BorrowSupplyDto;
import com.cupk.mapper.BorrowSupplyMapper;
import com.cupk.service.BorrowSupplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 名称BorrowSupplyServiceImpl
 * 描述物资申请实现类
 *
 * @version 1.0
 * @author:XiongRuiKai
 * @datatime:2023-06-11 21:19
 */
@Service
public class BorrowSupplyServiceImpl implements BorrowSupplyService {


    @Autowired
    private BorrowSupplyMapper borrowSupplyMapper;



    /**
     * 物资申请分页查询
     * @param goodsTypeId 物资编号
     * @param departmentContactName 部门联系人
     * @param goodsName 物资姓名
     * @param page 页码
     * @param pageSize 每页返回的数据条目数
     * @return
     */
    @Override
    public PageResult<BorrowSupplyDto> getQueryResultsWithPaging(Integer goodsTypeId, String departmentContactName, String goodsName, int page, int pageSize) {
        int start = (page - 1) * pageSize;
        int limit = pageSize;

        List<BorrowSupplyDto> queryResultDTOs = borrowSupplyMapper.getQueryResultsWithPaging(goodsTypeId,departmentContactName,goodsName,start, limit);
        int totalCount = borrowSupplyMapper.countQueryResults(goodsTypeId,departmentContactName,goodsName);

        return new PageResult<>(queryResultDTOs, totalCount);
    }
}
